<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<style type="text/css">
.modify{
	width:50px;
	}
</style>
<link rel="stylesheet" href="/js/chosen/chosen.css" />
</head>

<body  >
<div style="font-family:Arial, Helvetica, sans-serif;" >
<div id="message"></div>
<h1>Modify Order:</h1>
<h2><?php echo $this->errorMsg;?></h2>
<form id="form1" name="form1" method="post" action="">

<br />

All Extra Added Barcode will show in <span style="background:#6666CC;">Dark Purple Color 
<br />
Please use "," to seperate barcode<br/></span>
All added barcode if exist , order qty will auto + 1, Show in <span style="background:#66CC33;">Green Color</span><br/>
<?php /*?>
<select name = "code_add" class="chzn-select" style="width:800px">
<?php foreach ($this->optionList as $key => $title){?>
<option disabled selected>Please Select</option>
<option value = "<?php echo $key?>"><?php echo $key."(".$title.")"?></option>
<?php }?>
</select>
*/ ?>
<textarea name="code_add" rows="3" id="code_add" style="width:600px;"></textarea>
<br />
<br />
<input type="submit" name="btn_add_code" id="btn_add_code" value="Add Barcode" />
<br />

<h2 style="color:#093">AUTO SAVING FUNCTION IS NOW TURNED ON</h2>
<br />
<h3>New Added Product</h3>
<table width="1100" border="1" cellspacing="0" cellpadding="10" style="font-size:13px;" id="product_table">
<thead> 
  <tr>
    <th rowspan="2" scope="col">No</th>
    <th rowspan="2" scope="col">Hot</th>
    <th rowspan="2" scope="col">Code</th>
    <th width="350" rowspan="2" scope="col">Des</th>
    <th colspan="3" scope="col">Sales<br /></th>
    <th colspan="2" scope="col">Stock</th>
    <th rowspan="2" scope="col">Reco-<br />
      mmend</th>
    <th rowspan="2" scope="col">Order</th>

  </tr>

  <tr>
    <th scope="col">2Wk <br />
      Ago</th>
    <th scope="col">Last<br />
      Wk</th>
    <th scope="col">Max<br />
      4Wk</th>
    <th scope="col">SH</th>
    <th scope="col">WH</th>
  </tr>
 </thead> 
 <tfoot> 
  <tr>
    <th rowspan="2" scope="col">No</th>
    <th rowspan="2" scope="col">Hot</th>
    <th rowspan="2" scope="col">Code</th>
    <th width="350" rowspan="2" scope="col">Des</th>
    <th colspan="3" scope="col">Sales<br /></th>
    <th colspan="2" scope="col">Stock</th>
    <th rowspan="2" scope="col">Reco-<br />
      mmend</th>
    <th rowspan="2" scope="col">Order</th>

  </tr>

  <tr>
    <th scope="col">2Wk <br />
      Ago</th>
    <th scope="col">Last<br />
      Wk</th>
    <th scope="col">Max<br />
      4Wk</th>
    <th scope="col">SH</th>
    <th scope="col">WH</th>
  </tr>
 </tfoot>  
 <tbody>
  <?php 
  
  $locs = new Model_Products_Location();
  $x = 1;
  $y = 1;
  foreach($this->orderList as $idCate => $detail){

  foreach($detail as $k => $v){
  	if($v['is_extra'] == 1){?>
  <tr >
    <td align="center"><?php echo $x++;?></td>
    <td><?php echo $v['status_hot'];?></td>
    <td><span <?php  
	if($v['is_extra'] == 1){echo 'style="background:#6666CC;"'; }
	?>
	><?php echo $v['code_product'];?></span></td>
    <td><span <?php 
	if($v['is_extra'] == 1){echo 'style="background:#6666CC;"'; }
	
	?> ><?php echo $v['des_product'];?></span></td>
    <td align="center"><?php echo $v['qty_sales_w2'];?></td>
    <td align="center"><?php echo $v['qty_sales_w1'];?></td>
    <td align="center"><?php echo $v['qty_max_sold'];?></td>
    <td align="center"><?php echo $v['stock_shop'];?></td>
    <td align="center"><?php echo $v['stock_wh'];?></td>
    <td align="center"><span style="color:#AAA;"><?php echo $v['qty_order'];?></span></td>
    <td align="center"><input type="text" name="qty_order[<?php echo $v['id_order'];?>]" id="qty_order<?php echo $v['id_order'];?>"  value="<?php echo $v['qty_order_shop'];?>" class="modify" <?php echo ($this->isLocked)?'disabled="disabled"':'';?>/></td>
  
  </tr>
  <?php }
  	}
  }
  ?>
  </tbody>
  
</table>
<br/>


<h3>Order List</h3>
<table width="1100" border="1" cellspacing="0" cellpadding="10" style="font-size:13px;" id="product_table">
<thead> 
  <tr>
    <th rowspan="2" scope="col">No</th>
    <th rowspan="2" scope="col">Hot</th>
    <th rowspan="2" scope="col">Code</th>
    <th width="350" rowspan="2" scope="col">Des</th>
    <th colspan="3" scope="col">Sales<br /></th>
    <th colspan="2" scope="col">Stock</th>
    <th rowspan="2" scope="col">Reco-<br />
      mmend</th>
    <th rowspan="2" scope="col">Order</th>

  </tr>

  <tr>
    <th scope="col">2Wk <br />
      Ago</th>
    <th scope="col">Last<br />
      Wk</th>
    <th scope="col">Max<br />
      4Wk</th>
    <th scope="col">SH</th>
    <th scope="col">WH</th>
  </tr>
 </thead> 
 <tfoot> 
  <tr>
    <th rowspan="2" scope="col">No</th>
    <th rowspan="2" scope="col">Hot</th>
    <th rowspan="2" scope="col">Code</th>
    <th width="350" rowspan="2" scope="col">Des</th>
    <th colspan="3" scope="col">Sales<br /></th>
    <th colspan="2" scope="col">Stock</th>
    <th rowspan="2" scope="col">Reco-<br />
      mmend</th>
    <th rowspan="2" scope="col">Order</th>

  </tr>

  <tr>
    <th scope="col">2Wk <br />
      Ago</th>
    <th scope="col">Last<br />
      Wk</th>
    <th scope="col">Max<br />
      4Wk</th>
    <th scope="col">SH</th>
    <th scope="col">WH</th>
  </tr>
 </tfoot>  
 <tbody>
  <?php 
  
  $locs = new Model_Products_Location();
  foreach($this->orderList as $idCate => $detail){
 ?>
 <tr style=" background-color:#80FF80">
 <td >&nbsp;</td>
 <td>&nbsp;</td>
 <td>&nbsp;</td>
 <td ><strong style="line-height:25px; display:inline-block; font-size:18px;"><?php echo $this->arrOrderCate[$idCate];?></strong></td>
 <td>&nbsp;</td>
 <td>&nbsp;</td>
 <td>&nbsp;</td>
 <td>&nbsp;</td>
 <td>&nbsp;</td>
 <td>&nbsp;</td>
 <td>&nbsp;</td>
 </tr>
 <?	  

  foreach($detail as $k => $v){
  	if($v['is_extra'] != 1 || empty($v['is_extra'])){?>
  <tr >
    <td align="center"><?php echo $y++;?></td>
    <td><?php echo $v['status_hot'];?></td>
    <td><span <?php  
	if($v['is_extra'] == 2){echo 'style="background:#99CCFF;"'; }
	if($v['is_extra'] == 3){echo 'style="background:#66CC33;"'; }
	?>
	><?php echo $v['code_product'];?></span></td>
    <td><span <?php 
	if($v['is_extra'] == 2){echo 'style="background:#99CCFF;"'; }
	if($v['is_extra'] == 3){echo 'style="background:#66CC33;"'; }
	?> ><?php echo $v['des_product'];?></span></td>
    <td align="center"><?php echo $v['qty_sales_w2'];?></td>
    <td align="center"><?php echo $v['qty_sales_w1'];?></td>
    <td align="center"><?php echo $v['qty_max_sold'];?></td>
    <td align="center"><?php echo $v['stock_shop'];?></td>
    <td align="center"><?php echo $v['stock_wh'];?></td>
    <td align="center"><span style="color:#AAA;"><?php echo $v['qty_order'];?></span></td>
    <td align="center"><input type="text" name="qty_order[<?php echo $v['id_order'];?>]" id="qty_order<?php echo $v['id_order'];?>"  value="<?php echo $v['qty_order_shop'];?>" class="modify" <?php echo ($this->isLocked)?'disabled="disabled"':'';?>/></td>
  
  </tr>
  <?php }
  	}
  }
  ?>
  </tbody>
  
</table>
<br />
<h2 style="color:#093">AUTO SAVING FUNCTION IS NOW TURNED ON</h2>
<br />

</form>
<div style="border:#060 solid 2px; padding:5px; width:700px; text-align:center; background-color:#BFB">
<h2><a href="/products/modify-weeks-order-summary/no_order/<?php echo $this->noOrder;?>/shop/<?php echo $this->shop?>" style="text-decoration:none; color:#000;" >I have done the modification, check the summary</a></h2>
</div>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="/js/chosen/chosen.jquery.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
	$(".modify").change(function(){
		var qty = $(this).val();
		var idlong =  $(this).attr('id');
		id = idlong.substr(9);

		var url = "/products/service-update-weekly-order-qty/id_order/" + id + "/qty_order/" + qty;
		$.get(url,function(result){
			if(result = "SUCCESS"){
				// change value and color 
				//alert("SU");
				$("#" + idlong).css('background-color','#66CC33');
				}else{
					
				alert("AUTO SAVE FAIL, PLEASE CONTACT NORMAN IMMEDIATELLY");	
					}
			
			});
		});
	
	});

var config = {
  '.chzn-select': {allow_single_deselect:true},
}
for (var selector in config) {
  $(selector).chosen(config[selector]);
}
</script>
</body>
</html>
